% ternary demo1
% ----------------------
% @author : slandarer
% 公众号  : slandarer随笔
% 知乎    : slandarer

figure('Name','ternary demo1_1','Units','normalized','Position',[.05,.2,.42,.56])

% 初始化三元相图(Init ternary plot)
STA1=STernary();

% 背景色变为灰色(Set the background color to gray)
set(STA1,'Color',[.9,.9,.9]);

% 设置标签文本(Set Label string)
set(STA1,'A_Label','String','AAAAA')
set(STA1,'B_Label','String','BBBBB')
set(STA1,'C_Label','String','CCCCC')


% 绘制散点图(Draw scatter plot)
A=rand(1,20);
B=rand(1,20);
C=rand(1,20);
STA1.SScatter(A,B,C,40,'filled','CData',[0,0,0]);
legend()

% 以下两种用法等价(The following two uses are equivalent)
% set(STA,'XXX','prop',.......)
% STA.set('XXX','prop',.......)

% 设置A轴颜色和粗细(Set A_Axis's 'Color' and 'LineWidth')
set(STA1,'A_Axis','Color',[0,0,.8],'LineWidth',3)
% 设置A轴主网格颜色和粗细(Set A_Grid's 'Color' and 'LineWidth')
set(STA1,'A_Grid','Color',[0,0,.8],'LineWidth',1.2)
% 设置A轴次网格颜色线形
set(STA1,'A_MinorGrid','Color',[0,0,.8],'LineStyle','-.')
% 设置A轴主刻度颜色
set(STA1,'A_Tick','Color',[0,0,.8])
% 设置A轴次刻度颜色
set(STA1,'A_MinorTick','Color',[0,0,.8])
% 设置A轴刻度标签字体和颜色
set(STA1,'A_TickLabel','Color',[0,0,.8],'FontSize',16)
% 设置A轴标签字体和颜色及位置以及文本内容
set(STA1,'A_Label','Color',[0,0,.8],'FontSize',18,'Position',[.88,.6],'String',{'Ternary plot';'by Slandarer'})




%% ------------------------------------------------------------------------
figure('Name','ternary demo1_2','Units','normalized','Position',[.5,.2,.42,.56])

STA2=STernary();

% 将标签移动到侧边(Move the label to the side)
STA2.label2Side();

% 设置刻度长度(Set tick length)
STA2.set('TickLenth',[.035,.02])

% 设置刻度值/网格值/刻度标签
% 'GridValues'/'TickValues'
% 'MinorGridValues'/'MinorTickValues'
% 'A_TickLabelStr'/'B_TickLabelStr'/'C_TickLabelStr'
STA2.set('MinorGridValues',5:5:100)
STA2.set('MinorTickValues',2.5:2.5:100)
STA2.set('A_TickLabelStr',{'20%','40%','60%','80%','100%'})

